home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / util / blank / bserver_v14.lha / BServer_v1.4 / Sources.lha / Sources / clients / Line.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-23  |  4.2 KB  |  195 lines

  1. ;/*
  2. sc RESOPT IGNORE=73 DATA=NEAR NMINC UCHAR CONSTLIB STREQ STRMERGE NOSTKCHK NOSTDIO OPTIMIZE OPTSIZE Line.c
  3. slink from LIB:c.o Line.o to //Clients/Line LIB LIB:sc.lib LIB:amiga.lib /lib/client.lib SC SD NOICONS STRIPDEBUG
  4. delete Line.o
  5. quit
  6.  
  7.  Line 1.2  (Client for BServer)
  8.  
  9.  Copyright © 1994-1995 by Stefano Reksten of 3AM - The Three Amigos!!!
  10.  All rights reserved.
  11. */
  12.  
  13. #include <exec/types.h>
  14. #include <intuition/intuition.h>
  15.  
  16. #include <proto/exec.h>
  17. #include <proto/intuition.h>
  18. #include <proto/graphics.h>
  19. #include <clib/alib_protos.h>
  20. #include <stdlib.h>
  21. #include <time.h>
  22.  
  23. #include "/include/client.h"
  24.  
  25. char *ver = "$VER: Line 1.2 "__AMIGADATE__;
  26.  
  27. struct IntuitionBase *IntuitionBase;
  28. struct GfxBase *GfxBase;
  29.  
  30. struct DisplayIDInformation *dinfo;
  31.  
  32. #define LINENUM 40
  33. #define LASTLINE 39
  34.  
  35. struct { WORD FromX, FromY, ToX, ToY; } Line[LINENUM];
  36. WORD IncX, IncY, IncTX, IncTY;
  37.  
  38. extern ULONG RangeSeed;
  39.  
  40. void DrawLine( void )
  41. {
  42. UWORD n, swidth, sheight;
  43. struct Rectangle *rect;
  44. register ULONG total_Line = 0;
  45. UBYTE r, g, b, brightness;
  46. struct Screen *scr;
  47.  
  48. rect = GETTXTOSCANRECT(dinfo);
  49.  
  50. swidth = RECTANGLEWIDTH(rect);
  51. sheight = RECTANGLEHEIGHT(rect);
  52. brightness = GETBRIGHTNESS(dinfo);
  53.  
  54. if ( scr = OpenScreenTags( NULL,
  55.     SA_DisplayID, DISPLAYID( dinfo ),
  56.     SA_Width, swidth,
  57.     SA_Height, sheight,
  58.     SA_Left, (RECTANGLEWIDTH(rect) - swidth)/2,
  59.     SA_Top, 0,
  60.     SA_Depth, 1,
  61.     SA_Overscan, OSCAN_TEXT,
  62.     SA_Type, CUSTOMSCREEN,
  63.     SA_Quiet, TRUE,
  64.     TAG_END ) )
  65.     {
  66.     register struct ViewPort *vp = &(scr->ViewPort);
  67.     register struct RastPort *rp = &(scr->RastPort);
  68.  
  69.     SpritesOff();
  70.  
  71.     r = 6*brightness/100; g = 7*brightness/100; b = 9*brightness/100;
  72.     SetRGB4( vp, 0, 0, 0, 0 );
  73.     SetRGB4( vp, 1, r, g, b );
  74.     SetAPen( rp, 1 );
  75.     SetDrMd( rp, COMPLEMENT );
  76.  
  77.     Line[0].FromX = RangeRand( swidth );
  78.     Line[0].FromY = RangeRand( sheight );
  79.     Line[0].ToX = RangeRand( swidth - Line[0].FromX + 4);
  80.     Line[0].ToY = RangeRand( sheight - Line[0].FromY + 4);
  81.  
  82.     IncX = RangeRand( 40 ) - 19;
  83.     IncY = RangeRand( 40 ) - 19;
  84.     IncTX = RangeRand( 40 ) - 19;
  85.     IncTY = RangeRand( 40 ) - 19;
  86.  
  87.     while( STILL_BLANKING )
  88.         {
  89.         WaitTOF();
  90.  
  91.         if ( total_Line++ > LASTLINE )
  92.             {
  93.             Move( rp, Line[LASTLINE].FromX, Line[LASTLINE].FromY );
  94.             Draw( rp, Line[LASTLINE].ToX, Line[LASTLINE].ToY );
  95.             }
  96.  
  97.         for ( n = LASTLINE; n; n-- )
  98.             {
  99.             Line[n].FromX = Line[n-1].FromX;
  100.             Line[n].FromY = Line[n-1].FromY;
  101.             Line[n].ToX = Line[n-1].ToX;
  102.             Line[n].ToY = Line[n-1].ToY;
  103.             }
  104.  
  105.         if ( Line[0].FromX + IncX <= 0 )
  106.             {
  107.             Line[0].FromX = 0;
  108.             IncX = RangeRand( 20 ) + 1;
  109.             }
  110.         else
  111.         if ( Line[0].FromX + IncX >= swidth )
  112.             {
  113.             Line[0].FromX = swidth - 1;
  114.             IncX = RangeRand( 20 ) * (-1) - 1;
  115.             }
  116.         else
  117.             Line[0].FromX += IncX;
  118.  
  119.         if ( Line[0].FromY + IncY < 0 )
  120.             {
  121.             Line[0].FromY = 0;
  122.             IncY = RangeRand( 20 ) + 1;
  123.             }
  124.         else
  125.         if ( Line[0].FromY + IncY >= sheight )
  126.             {
  127.             Line[0].FromY = sheight - 1;
  128.             IncY = RangeRand( 20 ) * (-1) - 1;
  129.             }
  130.         else
  131.             Line[0].FromY += IncY;
  132.  
  133.         if ( Line[0].ToX + IncTX <= 0 )
  134.             {
  135.             Line[0].ToX = 0;
  136.             IncTX = RangeRand( 20 ) + 1;
  137.             }
  138.         else
  139.         if ( Line[0].ToX + IncTX >= swidth )
  140.             {
  141.             Line[0].ToX = swidth - 1;
  142.             IncTX = RangeRand( 20 ) * (-1) - 1;
  143.             }
  144.         else
  145.             Line[0].ToX += IncTX;
  146.  
  147.         if ( Line[0].ToY + IncTY < 0 )
  148.             {
  149.             Line[0].ToY = 0;
  150.             IncTY = RangeRand( 20 ) + 1;
  151.             }
  152.         else
  153.         if ( Line[0].ToY + IncTY >= sheight )
  154.             {
  155.             Line[0].ToY = sheight - 1;
  156.             IncTY = RangeRand( 20 ) * (-1) - 1;
  157.             }
  158.         else
  159.             Line[0].ToY += IncTY;
  160.  
  161.         Move( rp, Line[0].FromX, Line[0].FromY );
  162.         Draw( rp, Line[0].ToX, Line[0].ToY );
  163.  
  164.         r += RangeRand( 3 ) - 1; if ( r < 0 ) r = 0; if ( r > 15 ) r = 15;
  165.         g += RangeRand( 3 ) - 1; if ( g < 0 ) g = 0; if ( g > 15 ) g = 15;
  166.         b += RangeRand( 3 ) - 1; if ( b < 0 ) b = 0; if ( b > 15 ) b = 15;
  167.         SetRGB4( vp, 1, r*brightness/100, g*brightness/100, b*brightness/100 );
  168.         }
  169.  
  170.     CloseScreen( scr );
  171.     SpritesOn();
  172.     }
  173. else
  174.     SendClientMsg( ACTION_FAILED );
  175. }
  176.  
  177.  
  178. void __main( char *line )
  179. {
  180. if ( IntuitionBase = (struct IntuitionBase *)OpenLibrary( "intuition.library", 37L ) )
  181.     {
  182.     if ( GfxBase = (struct GfxBase *)OpenLibrary( "graphics.library", 37L ) )
  183.         {
  184.         if ( dinfo = OpenCommunication() )
  185.             {
  186.             RangeSeed = time( NULL );
  187.             DrawLine();
  188.             CloseCommunication( dinfo );
  189.             }
  190.         CloseLibrary( (struct Library *)GfxBase );
  191.         }
  192.     CloseLibrary( (struct Library *)IntuitionBase );
  193.     }
  194. }
  195.